import { useRoute, useRouter } from 'vue-router';

export function useGo() {
    const { push, replace } = useRouter();
    function goPath(path, isReplace = false) {
        if (isReplace) {
            replace(path);
        } else {
            push(path);
        }
    }
    return goPath;
}

export function useQuery(isParams = false): any {
    const route = useRoute();
    const getData = () => {
        if (isParams) {
            return route.params;
        }
        return route.query;
    };
    return getData();
}
